<%@ page import="org.jeecgframework.web.util.StaticValue" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
    <div region="center" style="padding:1px;">
        <t:datagrid name="cbsReturnEquipmentList" fitColumns="false" title="待返件任务"
                    actionUrl="cbsReturnEquipmentController.do?datagridWL" idField="id" fit="true" queryMode="group"  onLoadSuccess="changeColor">
            <t:dgCol title="主键" field="id" hidden="true" queryMode="single" width="120"></t:dgCol>
            <t:dgCol title="返件单号" field="code" queryMode="single" url="cbsReturnEquipmentController.do?detailesWL&id={id}"
                     funname="openDetailes" width="120" query="true"></t:dgCol>
            <t:dgCol title="返件状态" field="status" queryMode="single" width="80" query="true"
                     dictionary="<%= StaticValue.RETURN_STATUS_Log_Type %>"></t:dgCol>
            <t:dgCol title="SO" field="so" queryMode="single" width="100" query="true"></t:dgCol>
            <t:dgCol title="影院名称" field="cinemaName"  queryMode="single" width="220" query="true"></t:dgCol>
            <t:dgCol title="省份" field="shengName" query="true" queryMode="single" width="120" ></t:dgCol>
            <t:dgCol title="城市" field="shiName" query="true" queryMode="single" width="120" ></t:dgCol>
            <t:dgCol title="备件类型" field="typedes" queryMode="single" width="150"></t:dgCol>
            <t:dgCol title="备件号" field="item" queryMode="single" width="180"></t:dgCol>
            <t:dgCol title="备件数量" field="itemtotal" queryMode="single" width="100"></t:dgCol>
            <t:dgCol title="通知返件时间" field="noticeReturnTime" formatter="yyyy-MM-dd" queryMode="group" width="100" query="true"></t:dgCol>
            <t:dgCol title="预计取件时间" field="pickupTime" formatter="yyyy-MM-dd"   query="true" queryMode="group"
                     width="100"></t:dgCol>
            <t:dgCol title="入库时间" field="backTime" formatter="yyyy-MM-dd"  query="true" queryMode="group"
                     width="100"></t:dgCol>
            <t:dgCol title="发货单号" field="delivercode" queryMode="single" width="120" query="true"></t:dgCol>
            <t:dgCol title="物流运单号" field="logisticscode" queryMode="single" width="120" query="true"></t:dgCol>
            <t:dgCol title="CR" field="cr" queryMode="single" width="100" query="true"></t:dgCol>
            <t:dgToolBar title="导出" icon="icon-putout" funname="ExportXls" operationCode="returnWl"></t:dgToolBar>
        </t:datagrid>
    </div>
</div>
<script src="webpage/com/zybk/com.returnEq/cbsReturnEquipmentList.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        //给时间控件加上样式
        $("#cbsReturnEquipmentListtb").find("input[name='createDate_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsReturnEquipmentListtb").find("input[name='createDate_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsReturnEquipmentListtb").find("input[name='noticeReturnTime_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsReturnEquipmentListtb").find("input[name='noticeReturnTime_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsReturnEquipmentListtb").find("input[name='backTime_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsReturnEquipmentListtb").find("input[name='backTime_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsReturnEquipmentListtb").find("input[name='pickupTime_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsReturnEquipmentListtb").find("input[name='pickupTime_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
    });

    //导出
    function ExportXls() {
        var currPageRows = $("#cbsReturnEquipmentList").datagrid("getRows");
        var idsData = [];
        $(currPageRows).each(function (i, rowData) {
            idsData.push(rowData.id);
        });
        if (idsData.length > 0) {
            myDownload("cbsReturnEquipmentController.do?exportXls1", "returnIds=" + idsData.join(","));
        } else {
            tip("当前页面没有数据可以导出");
        }
    }

    /*物流返件详情*/
    function openDetailes(filedName,url){
        var data = $('#cbsReturnEquipmentList').datagrid('getSelections');
        var code = data[0].code;
        if(data[0].status==4 ){
            addOneTab("返件详情"+code,'cbsReturnEquipmentController.do?detailesForAll&id='+data[0].id+'&type=WL');
        }else{
            addOneTab("返件详情"+code,url);
        }
    }

    /*待处理的文字为红色*/
    function changeColor() {
        var trs = $("#cbsReturnEquipmentList").prev().find('div.datagrid-body').find('tr');
        for (var i = 0; i < trs.length; i++) {
            for (var j = 0; j < 8; j++) {
                if (trs[i].cells[j].firstChild.innerHTML =='未返件')
                    trs[i].cells[j].style.cssText = 'color:red';
            }
        }
    }

</script>